<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-06-18
 * Time: 11:38
 */

namespace app\api\service\order;


use app\api\model\ProjectHatchCommentOrder;
use app\api\service\Token;
use think\Db;
use think\Exception;
use think\facade\Log;

class HatchCommentSer extends Token
{
    /**
     * 1.修改订单状态
     */

    // 订单信息
    private $order;

    function __construct($order)
    {
        $this->order = $order;
    }

    // 入口文件
    public function changeStatus()
    {
        if($this->order['status'] == 1) {
            Db::startTrans();
            try
            {
                // 更新订单状态
                $ProjectHatchCommentOrder = new ProjectHatchCommentOrder();
                $ProjectHatchCommentOrder->save([
                    'status' => 2
                ],[ 'id' => $this->order['id']]);
                Db::commit();
                return true;
            }
            catch (Exception $ex)
            {
                Db::rollback();
                throw $ex;
                return false;
            }
        } else {
            return true;
        }
    }
}